public class Test {
    public static void print(int n) {//打印每一位的数
        if (n < 10) {
            System.out.println(n);
        } else {
            print(n / 10);
            System.out.println(n % 10);
        }
        return;
    }

    public static int sum(int n) {//每一位加起来
        if (n == 0) {
            return 0;
        }
        return n % 10 + sum(n / 10);
    }
    public static int fun(int n){//求1+2+3....+n的合
        if(n==1){
            return 1;
        }
        return n+fun(n-1);
    }

    public static void main(String[] args) {
        print(1234);
        int add = 0;
        add = sum(9);
        System.out.println(add);
        int a=0;
        a=fun(5);
        System.out.println(a);
    }
}
